#include "AuthMapper.h"

#include "../DataSourceInstance.h"
#include "../common/YXMySQL.h"
#include "../common/YXString.h"

MYSQLResult *selectIdPasswordByUsername(char *username) {
    // 注意：这里直接用字符串拼接（有sql注入风险）
    static char *sqlTemplate = "select id, password from user where username = '%s'";
    char        *sql         = yxString_printf(sqlTemplate, username);

    Connection *connection = getConnection(dataSource);
    MYSQLResult* result = exceuteQuery(connection, sql);
    returnConnection(dataSource, connection);

    return result;
}